package web.Servlet;

import Service.yuliangService;
import domain.yuliang;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(name = "yuliangServlet",urlPatterns = "/yl")
public class yuliangServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList arrayList = new ArrayList();
        yuliangService yuliangService = new yuliangService();
        try {
            List<yuliang> all = yuliangService.findAll(arrayList);
            req.setAttribute("list",all);
            req.getRequestDispatcher("admin.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
